global root_path "/Volumes/Workgroup/Lab/Lab-heimb/Montenovo/Volunteering Paper/Data"

clear all
set maxvar 32767

cd "$root_path/02_ready_for_PSIDclean"

use individ_family_2003.dta, clear

cd "$root_path/03_ready_for_TAXSIM"


gen unique_id_crossys=(ER30001*1000) + ER30002
//egen ID_unique_year=group(ER33602 ER17002)
gen sequence_num=ER33702

//order ER30001 ER30002 sequence_num unique_id_crossys ID_unique_year ER32000 ER17002  ER17011 ER17013 ER17014 ER17015 ER17016  ER20089 ER20097 ER20369 ER20088 ER20096
//browse ER30001 ER30002 sequence_num ID_unique_id_crossys ID_unique_year ER32000 ER17002  ER17011 ER17013 ER17014 ER17015 ER17016  ER20089 ER20097 ER20369 ER20088 ER20096




rename ER30000 release_number
rename ER30001 interview_number_1986
rename ER30002 person_number

**HH ID
rename ER21002 family_id

** State of residence.
rename ER21003 state_residence

** RAW FIELDS.
** Marriage stuff.
rename ER21023 marital_status_head
rename ER21018 sex_head

gen married=0
replace married=1 if marital_status_head==1

keep if (sequence_num==1 & married==0) | (sequence_num==1 & married==1) | (sequence_num==2 & married==1)


** Children.
rename ER21020 children
** Ages.
rename ER21017 age_head
rename ER21019 age_wife

** Race

* wife
gen white_w=0
replace white_w=1 if ER23334==1 & ER23335==0 & ER23336==0 & ER23337==0

gen black_w=0
replace black_w=1 if ER23334==2 & ER23335==0 & ER23336==0 & ER23337==0

gen native_amer_w=0
replace native_amer_w=1 if ER23334==3 & ER23335==0 & ER23336==0 & ER23337==0

gen asian_w=0
replace asian_w=1 if ER23334==4 & ER23335==0 & ER23336==0 & ER23337==0

*gen latino_w=0
*replace latino_w=1 if ER23334==5 & ER23335==0 & ER23336==0 & ER23337==0

gen other_w=0
replace other_w=1 if (ER23334>=5)
replace other_w=1 if ER23335!=0 | ER23336!=0 | ER23337!=0

gen any_race_w=white_w+black_w+native_amer_w+asian_w+other_w
sum any_race_w

*  3,721 have no recorded race in OUR data
*  3,524: no wife present
*  3,721-3,524 are mixed race so we did not code them yet

* husband
gen white_h=0
replace white_h=1 if ER23426==1 & ER23427==0 & ER23428==0 & ER23429==0

gen black_h=0
replace black_h=1 if ER23426==2 & ER23427==0 & ER23428==0 & ER23429==0

gen native_amer_h=0
replace native_amer_h=1 if ER23426==3 & ER23427==0 & ER23428==0 & ER23429==0

gen asian_h=0
replace asian_h=1 if ER23426==4 & ER23427==0 & ER23428==0 & ER23429==0

*gen latino_h=0
*replace latino_h=1 if ER23426==5 & ER23427==0 & ER23428==0 & ER23429==0

gen other_h=0
replace other_h=1 if (ER23426>=5)
replace other_h=1 if ER23427!=0 | ER23428!=0 | ER23429!=0

gen any_race_h=white_h+black_h+native_amer_h+asian_h+other_h
sum any_race_h

order interview_number_1986 marital_status_head unique_id_crossys sequence_num white_w black_w    white_h black_h    ER32000 age_head age_wife

order interview_number_1986 family_id marital_status_head unique_id_crossys sequence_num white_w black_w   white_h black_h    ER32000 age_head age_wife




*  7,524 have no recorded race in OUR data
*  298: are mixed race so we did not code them yet

** GENERATED FIELDS.
rename ER24105 farm_inc_head_gen
rename ER22003 rent_inc_head
rename ER22004 rent_inc_head_unit
rename ER22336 rent_inc_wife
rename ER22337 rent_inc_wife_unit
rename ER24110 unincorp_assetpt_inc_head_gen
rename ER24129 gardening_inc_head_gen
rename ER22233 alimony_inc_head
rename ER22234 alimony_inc_head_unit
rename ER24111 unincorp_assetpt_inc_wife_gen
rename ER22037 interest_inc_head
rename ER22038 interest_inc_head_unit
rename ER22370 interest_inc_wife
rename ER22371 interest_inc_wife_unit

rename ER24100 taxable_inc_hh_gen
rename ER24135 labor_inc_wife_gen

rename ER22020 dividend_inc_head
rename ER22021 dividend_inc_head_unit
rename ER22353 dividend_inc_wife
rename ER22354 dividend_inc_wife_unit
rename ER24116 labor_inc_head_gen

rename ER22548 alimony_given

rename ER22136 nonva_retire_inc_head
rename ER22137 nonva_retire_inc_head_unit
rename ER22468 retire_annuities_inc_wife
rename ER22469 retire_annuities_inc_wife_unit

rename ER24104 socsec_inc_fu

rename ER22087 ssi_inc_head
rename ER22088 ssi_inc_head_unit
rename ER22404 ssi_inc_wife
rename ER22405 ssi_inc_wife_unit
rename ER22120 vapension_inc_head
rename ER22121 vapension_inc_head_unit
rename ER22201 workerscomp_inc_head
rename ER22202 workerscomp_inc_head_unit
rename ER22320 workerscomp_inc_wife
rename ER22321 workerscomp_inc_wife_unit
rename ER22070 tanf_inc_head
rename ER22071 tanf_inc_head_unit
rename ER22420 tanf_inc_wife
rename ER22421 tanf_inc_wife_unit
rename ER22103 otherwelfare_inc_head
rename ER22104 otherwelfare_inc_head_unit
rename ER22452 otherwelfare_inc_wife
rename ER22453 otherwelfare_inc_wife_unit
rename ER22217 childsupport_inc_head
rename ER22218 childsupport_inc_head_unit
rename ER22436 childsupport_inc_wife
rename ER22437 childsupport_inc_wife_unit

** Rent.
rename ER21072 rent_amount
rename ER21073 rent_amount_unit

** Taxes.
rename ER21045 property_tax_annual

** Deductions.
rename ER22534 whether_itemized
rename ER22535 itemized_charitable
rename ER22536 itemized_medical

** Child care.
rename ER21628 childcare_expense

** Unemployment.
rename ER22185 unemployment_inc_head
rename ER22186 unemployment_inc_head_unit
rename ER22304 unemployment_inc_wife
rename ER22305 unemployment_inc_wife_unit

** Mortgage payments.
rename ER21051 mortgage1_principle_remaining
rename ER21055 mortgage1_interest_rate_wholenum
rename ER21056 mortgage1_interest_rate_fraction

** Food consumption.
rename ER21682 food_stamps
rename ER21683 food_stamps_unit
rename ER21686 food_homestamps
rename ER21687 food_homestamps_unit
rename ER21690 food_deliveredstamps
rename ER21691 food_deliveredstamps_unit
rename ER21693 food_awaystamps
rename ER21694 food_awaystamps_unit
rename ER21696 food_home
rename ER21697 food_home_unit
rename ER21700 food_delivered
rename ER21701 food_delivered_unit
rename ER21703 food_away
rename ER21704 food_away_unit

*donations

rename ER23481 whether_donation25_religious
rename ER23482 whether_donation_religious
rename ER23483 amount_donation_religious
rename ER23488 whether_donation_combo
rename ER23489 amount_donation_combo
rename ER23494 whether_donation_needy
rename ER23495 amount_donation_needy
rename ER23500 whether_donation_health
rename ER23501 amount_donation_health
rename ER23506 whether_donation_education
rename ER23507 amount_donation_education
rename ER23512 whether_donation_youth
rename ER23513 amount_donation_youth
rename ER23518 whether_donation_culture
rename ER23519 amount_donation_culture
rename ER23524 whether_donation_community
rename ER23525 amount_donation_community
rename ER23530  whether_donation_environment
rename ER23531 amount_donation_environment
rename ER23536 whether_donation_peace
rename ER23537 amount_donation_peace
rename ER23542 whether_donation_other
rename ER23543 amount_donation_other
rename ER23542A donation_type_other_org


// Religious volunteering

rename ER23559 calcul_yr_hs_reli_hd
rename ER23569 calcul_yr_hs_reli_wf

rename ER23560 calcul_yr_hs_reli_right_hd
rename ER23570 calcul_yr_hs_reli_right_wf

rename ER23561 your_estim_yr_hs_reli_hd
rename ER23571 your_estim_yr_hs_reli_wf

rename ER23563 estim_yr_hs_reli_extra_hd
rename ER23573 estim_yr_hs_reli_extra_wf

// Youth

rename ER23578 calcul_yr_hs_youth_hd
rename ER23587 calcul_yr_hs_youth_wf

rename ER23579 calcul_yr_hs_youth_right_hd
rename ER23588 calcul_yr_hs_youth_right_wf

rename ER23580 your_estim_yr_hs_youth_hd
rename ER23589 your_estim_yr_hs_youth_wf

rename ER23582 estim_yr_hs_youth_extra_hd
rename ER23591 estim_yr_hs_youth_extra_wf

// Senior

rename ER23596 calcul_yr_hs_senior_hd
rename ER23605 calcul_yr_hs_senior_wf

rename ER23597 calcul_yr_hs_senior_right_hd
rename ER23606 calcul_yr_hs_senior_right_wf

rename ER23598 your_estim_yr_hs_senior_hd
rename ER23607 your_estim_yr_hs_senior_wf

rename ER23600 estim_yr_hs_senior_extra_hd
rename ER23609 estim_yr_hs_senior_extra_wf

//Health

rename ER23614 calcul_yr_hs_health_hd
rename ER23623 calcul_yr_hs_health_wf

rename ER23615 calcul_yr_hs_health_right_hd
rename ER23624 calcul_yr_hs_health_right_wf

rename ER23616 your_estim_yr_hs_health_hd
rename ER23625 your_estim_yr_hs_health_wf

rename ER23618 estim_yr_hs_health_extra_hd
rename ER23627 estim_yr_hs_health_extra_wf

//Needy

rename ER23632 calcul_yr_hs_needy_hd
rename ER23641 calcul_yr_hs_needy_wf

rename ER23633 calcul_yr_hs_needy_right_hd
rename ER23642 calcul_yr_hs_needy_right_wf

rename ER23634 your_estim_yr_hs_needy_hd
rename ER23643 your_estim_yr_hs_needy_wf

rename ER23636 estim_yr_hs_needy_extra_hd
rename ER23645 estim_yr_hs_needy_extra_wf

//Social Change

rename ER23650 calcul_yr_hs_change_hd
rename ER23659 calcul_yr_hs_change_wf

rename ER23651 calcul_yr_hs_change_right_hd
rename ER23660 calcul_yr_hs_change_right_wf

rename ER23652 your_estim_yr_hs_change_hd
rename ER23661 your_estim_yr_hs_change_wf

rename ER23654 estim_yr_hs_change_extra_hd
rename ER23663 estim_yr_hs_change_extra_wf

//Other

rename ER23669 calcul_yr_hs_other_hd
rename ER23679 calcul_yr_hs_other_wf

rename ER23670 calcul_yr_hs_other_right_hd
rename ER23680 calcul_yr_hs_other_right_wf

rename ER23671 your_estim_yr_hs_other_hd
rename ER23681 your_estim_yr_hs_other_wf

rename ER23673 estim_yr_hs_other_extra_hd
rename ER23683 estim_yr_hs_other_extra_wf

rename ER23686 hs_other_religious
rename ER23688 hs_other_youth
rename ER23690 hs_other_senior
rename ER23692 hs_other_health
rename ER23694 hs_other_needy
rename ER23696 hs_other_socialchange
rename ER23697A volunteer_type_other_oth
rename ER23698 hs_type_other

rename ER21409 hr_wage_spouse
rename ER21159 hr_wage_hd
rename ER21929 tot_wage_hd
rename ER22300 tot_wage_spouse
rename ER24080 tot_hs_worked_head
rename ER24091 tot_hs_worked_spouse

rename ER23474 religion_hd
rename ER23382 religion_spouse
rename ER24144A rural

rename ER22184 whether_unemployed_head
rename ER22303 whether_unemployed_spouse

drop ER*

save fam2003er-small.dta, replace 
